<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>评论</title>
		<link rel="stylesheet" type="text/css" href="css/index.css" />
		<script type="text/javascript" src="js/jquery-1.12.0.min.js"></script>
		<script src="js/zepto.js"></script>
		<script type="text/javascript" src="js/touch.js"></script>
		<style type="text/css">
			
			#comment{
				width: 100%;
				height: 2rem;
				border-top: 1px solid #AFAFAF;
				border-bottom: 1px solid #AFAFAF;
				position: relative;
	
			}
			#comment .in_tex{
				width: 94%;
				height:90%;
				position: absolute;
				left: .1rem;
				top: .1rem;
				border: none;
				outline: none;
				font-size: .13rem;
			}
			.conpic{
				width: .7rem;
				height: .7rem;
				position: absolute;
				left: .1rem;
				bottom: .1rem;
				
				background: url(img/z_add.png) center center no-repeat;
				background-size: 100% 100%;
			}
			.conpic input::-webkit-file-upload-button {
				width: .4rem;
				height: .4rem;
				border: none;
				position: absolute;
				outline: 0;
				opacity: 0;
			}
			#filechooser{
				display: block;
				width: auto;
				border: 0;
				vertical-align: middle;
				background-color: darkgoldenrod;
			}
			.piclook{
				width: .8rem;
				height: .8rem;
				
				background-color: #F0F0F0;
				position: absolute;
				left: 10px;
				top: 1.1rem;
				overflow: hidden;
				z-index: 10;
			
				display: none;
 				vertical-align:middle;
 				font-size: 0;
    			text-align: center;
    			line-height: .8rem;
			}
			.piclook img{
				width: 100%;
				
				
				vertical-align:middle;
			}
			#sub{
				width: .4rem;
				height: .3rem;
				line-height: .3rem;
				text-align: center;
				/*position: absolute;
				right: .1rem;
				top:.1rem;*/
				border: 1px solid #F0F0F0;
				border-radius: .05rem;
				font-size: .1rem;
			}
			#texta{
				resize:none
			}
			.sanjiao_pic1{
				width: .2rem;
				height: .2rem;
				font-size: .2rem;
				line-height: .15rem;
				text-align: center;
				color: #AFAFAF;
				border: 1px solid #AFAFAF;
				border-radius: 50%;
				position: absolute;
				top:1rem;
				left:.8rem;
				z-index: 1000;
				display: none;
				
			}
			.btn{
				width: .7rem;
				height: .3rem;
				font-size:.13rem;
				float: left;
				text-align: center;
				letter-spacing: .03rem;
				line-height: .28rem;
				border: 1px solid black;
				border-radius: .05rem;
				background-color: black;
				color: white;
				margin-top: .08rem;
				margin-left: 3%;
			}
			.btn1{
				width: .7rem;
				height: .3rem;
				font-size:.13rem;
				float: right;
				text-align: center;
				letter-spacing: .03rem;
				line-height: .28rem;
				border: 1px solid black;
				border-radius: .05rem;
				background-color: black;
				color: white;
				margin-right: 3%;
				margin-top: .08rem;
				/*margin-left: 60%;*/
			}
			.inhidden{
				display: none;
			}
		</style>
	</head>
	<body>
		
		
		
		<div id="comment">
			
			
				<textarea class="in_tex" type="text" name="content" id="texta" value="" placeholder="说点什么吧..."></textarea>
				
		</div>
		<div class="btn"  onclick="history.back(-1)">
				取消
		</div>
		<div class="btn1" id="tijiaoping">
				发送
		</div>
	</body>
	<script type="text/javascript" src="js/exif.js"></script>	
	<script type="text/javascript">
		
		
		var userid = document.URL.split("?")[1].split("&")[0].split("=")[1];
		var commentId = document.URL.split("?")[1].split("&")[1].split("=")[1];
		var Name = decodeURI(document.URL.split("?")[1].split("&")[2].split("=")[1]);
	
	
		$('input[type="text"],textarea').on('focus', function () {
		  	var target = this;
		    setTimeout(function(){
		        target.scrollIntoViewIfNeeded();
		        console.log('scrollIntoViewIfNeeded');
		    },200);
		});
		$('input[type="text"],textarea').on('blur', function () {
			setTimeout(function(){
		        //$("#comment").css({display:"none"});
		    },200);
		});
//		$("#sanjiao_pic1").on("touchend",function(){
//					$("#piclook").empty();
//					$("#piclook").hide();
//					$("#sanjiao_pic1").hide();
//		});
		$(".in_tex").attr("placeholder","评论一下"+Name+"吧~~");
		$("#tijiaoping").on("touchend",function(){
			console.log(11)
			if($("#texta").val() == ""){
				alert("评论不能为空呦~")
			}else{
				var pl = $("#texta").val();
				
				$.ajax({
					url: 'http://test.onetuu.com/Valentines/addComment', //跨域到http://www.wp.com，另，http://test.com也算跨域
					type: 'post', //jsonp 类型下只能使用GET,不能用POST,这里不写默认为GET
					dataType: 'json', //指定为jsonp类型
					data: {
						"userid": userid,
						"commentId": commentId,
						"discourse": pl
					},
					success: function(data) {
						console.log(data);
						if(data.eligibility == 1) {
							window.location.href = "index.html?userid="+userid;
						}

					}
				});
				
				
				
			}
			
			
			
		})
	
		
		
		
	</script>
</html>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             